package com.tinshow.web;

import com.tinshow.config.Interceptor.CookieInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Hello world!
 */
@SpringBootApplication
@ComponentScan(basePackages = {"com.tinshow.web.controller", "com.tinshow.service"
        })
@MapperScan(basePackages="com.tinshow.dao.**")
//@EnableCaching
@EnableAsync
public class Application extends WebMvcConfigurerAdapter{
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);

    }

    @Override
    public void addInterceptors(InterceptorRegistry registry){
        registry.addInterceptor(new CookieInterceptor()).addPathPatterns("/**");
        super.addInterceptors(registry);
    }
}
